<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link href="../../build/common/base.css" rel="stylesheet">

  <link rel="stylesheet" href="../../build/form/form.css">
  <link rel="stylesheet" href="../../build/form/page.css">
  <link rel="stylesheet" href="../../build/form/preview.css">
  <link rel="stylesheet" href="../../assets/js/plugins/icheck/skins/all.css">
  <script type="text/javascript" src="../../build/common/base.js"></script>
  <script type="text/javascript" src="../../build/common/vueEdit.js"></script>
  <script src="../../assets/js/common/element/index.js"></script>

  <style>
    * {
      padding: 0px;
      margin: 0px;
    }

    ul li {
      list-style: none;
    }

    .my_cols {
      margin: 20px 0;
    }

    .my_box {
      height: calc(100% - 43px);
    }

    .my_table thead th {
      white-space: nowrap;
    }
  </style>
</head>

<body>
  <div id="ctrlC" style="padding: 0 30px;">
    <!-- <div style="width: 50%; margin: 0 auto; margin-top: 30px;">
      <button @click="handCols()" class="btn btn-primary my_cols consea">隐藏相同项</button>

     

    </div> -->
    <span @click="handSub()" class="btn btn-success fa fa-send mb30 mt30">提交</span>
    <span @click="handCos()" class="btn btn-success fa fa-send mb30 mt30">取消</span>
    <table style="width: 100%; margin: 0 auto;" class="table table-striped table-bordered table_hover text-center mb60">
      <tbody>
        <tr>
          <th>调查名称任务</th>
          <td><input class="form-control" v-model="surbeyObj.dcmcrw" type="text" name="" id=""  disabled="disabled"></td>
        </tr>
        <tr>
          <th>调查人员名称</th>
          <td><input class="form-control" v-model="surbeyObj.dcryid" type="text" name="" id=""  disabled="disabled"></td>
        </tr>
        <tr>
          <th>开始时间</th>
          <td><input class="form-control" v-model="surbeyObj.kssj" type="text" name="" id=""  disabled="disabled"></td>
        </tr>
        <tr>
          <th>频率月次</th>
          <td><input class="form-control" v-model="surbeyObj.plyc" type="text" name="" id=""  disabled="disabled"></td>
        </tr>
        <tr>
          <th>状态</th>
          <td><input class="form-control" v-model="surbeyObj.zt" type="text" name="" id=""  disabled="disabled"></td>
        </tr>
        <!--<tr>
          <th>调查人员id</th>
          <td><input class="form-control" v-model="surbeyObj.dccpid" type="text" name="" id=""></td>
        </tr>
        <tr>
          <th>调查内容id</th>
          <td><input class="form-control" v-model="surbeyObj.dcnrid" type="text" name="" id=""></td>
        </tr>
        <tr>
          <th>发起人员id</th>
          <td><input class="form-control" v-model="surbeyObj.fqryid" type="text" name="" id=""></td>
        </tr>-->
        <tr>
          <th>调查任务描述</th>
          <td><input class="form-control" v-model="surbeyObj.dcrwms" type="text" name="" id=""  disabled="disabled"></td>
        </tr>
        <tr>
          <th>调查时间</th>
          <td>
            <ab-date type="text" class=" form-control" v-model="staTime" desc="市场调查分配人员表-开始时间"
              v-ab-validate="{&quot;required&quot;:true}" format="yyyy-MM"></ab-date>
          </td>
        </tr>
      </tbody>
    </table>
    <a @click="handAdds()" href="javascript:;" class="btn btn-primary btn-sm mb20 mt20 mr5 btn-outline">添加一行</a>
    <table class="my_table table table-striped table-bordered table_hover text-center mb60">
      <thead>
        <tr>
<!--          <th>调查结果id</th>-->
          <th>供应商名称</th>
          <th>联系人</th>
          <th>调查价格</th>
          <th>规格</th>
          <th>单位</th>
          <th>交货方式</th>
          <th>付款方式</th>
          <th>运费包含</th>
          <th>损耗</th>
          <th>国标</th>
          <th>国标下差</th>
          <th>规模</th>
          <th>货期</th>
          <th>备注</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in addList" :key="index">
<!--          <td><input class="form-control" type="text" v-model="item.dcjgid"></td>-->
          <td><input class="form-control" type="text" v-model="item.gys"></td>
          <td><input class="form-control" type="text" v-model="item.lxr"></td>
          <td><input class="form-control" type="text" v-model="item.dcjg"></td>
          <td><input class="form-control" type="text" v-model="item.gg"></td>
          <td><input class="form-control" type="text" v-model="item.dw"></td>
          <td><input class="form-control" type="text" v-model="item.jhfs"></td>
          <td><input class="form-control" type="text" v-model="item.fkfs"></td>
          <td><input class="form-control" type="text" v-model="item.yfbh"></td>
          <td><input class="form-control" type="text" v-model="item.sh"></td>
          <td><input class="form-control" type="text" v-model="item.gb"></td>
          <td><input class="form-control" type="text" v-model="item.gbxc"></td>
          <td><input class="form-control" type="text" v-model="item.gm"></td>
          <td><input class="form-control" type="text" v-model="item.hq"></td>
          <td><input class="form-control" type="text" v-model="item.bz"></td>
          <td> <a @click="handDel(item.index)" href="javascript:;"
              class="btn btn-primary btn-sm mb20 mt20 mr5 btn-outline">删除</a>
          </td>
        </tr>
      </tbody>
    </table>




  </div>
</body>
<script type="text/javascript">

  // $(".consea").click(function () {

  // })






  var vm = new Vue({
    el: "#ctrlC",
    data: function () {
      return {
        staTime: "",
        surbeyObj: {},
        addList: [
          {
            index: 0,
            dcjgid: "",
            gys: "",
            lxr: "",
            dcjg: "",
            gg: "",
            dw: "",
            jhfs: "",
            fkfs: "",
            yfbh: "",
            sh: "",
            gb: "",
            gbxc: "",
            gm: "",
            hq: "",
            bz: "",
          }
        ]

      }
    },
    beforeCreate: function () {
    },
    created: function () {
      var id = location.search.replace("?", "")
      var ids = id.split(",")
      console.log("iddddddddd", ids[0])
      var that = this
      var url = "http://127.0.0.1:18084/materials/scdcfpryb/" + ids[0];
      var post = Vue.baseService.get(url);
      post.then(function (res) {
        console.log(res, "请求成功")
        that.surbeyObj = res
      }, function (status) {
        if (status == !0) {
          $.Toast.error('加载失败！' + status);
        }
      })
    },
    methods: {
      handCos: function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
        parent.layer.close(index);
      },
      handSub: function () {
        if (this.staTime == "") {
          $.Dialog.error("请选择调查时间")
          return
        } else {
          var id = location.search.replace("?", "")
          var ids = id.split(",")
          var that = this

          var list = JSON.stringify(that.addList)
          var jsObject = JSON.parse(list)
          console.log("list=====>>>", jsObject)
          // var url = "http://127.0.0.1:18084/materials/addFindings/" + ids[0] + "/" + ids[1] + "?" + "dcyf=" + this.staTime + "&lista=" + jsObject;
          // var post = Vue.baseService.get(url);
          // post.then(function (res) {
          //   console.log(res, "提交成功")
          //   that.surbeyObj = res
          //   // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
          //   // // parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
          //   // parent.layer.close(index);
          // }, function (status) {
          //   if (status == !0) {
          //     $.Toast.error('加载失败！' + status);
          //   }
          // })
          $.ajax({
            url: "http://127.0.0.1:18084/sys/gysgGysryxx/addFindingsService/" + ids[0] + "/" + ids[1] + "?" + "dcyf=" + this.staTime,
            type: "get",
           // dataType: "json",
            traditional: true,
            data: { list: list },
            success: function (res) {
              $.Toast.success("添加成功")
              var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
              parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
              parent.layer.close(index);
              console.log("服务res==>>", res, ids[1])
            }
          })
        }


      },
      handCols: function () {

      },
      handDel: function (index) {
        this.addList.splice(index, 1);
        for (let i in this.addList) {
          this.addList[i].index = i
        }
      },
      handAdds: function () {
        this.addList.push({
          index: this.addList.length,
          dcjgid: "",
          gys: "",
          lxr: "",
          dcjg: "",
          gg: "",
          dw: "",
          jhfs: "",
          fkfs: "",
          yfbh: "",
          sh: "",
          gb: "",
          gbxc: "",
          gm: "",
          hq: "",
          bz: "",
        })
      }

    },

    watch: {

    }
  });
</script>

</html>